package com.varian.tool.exception;

import cn.hutool.core.util.ArrayUtil;
import com.varian.tool.contant.ResultConstant;
import lombok.Getter;

/**
 * @author ben
 * @since 2024/6/22
 */
@Getter
public abstract class BaseException extends RuntimeException {

    private final Integer status;

    protected BaseException(Integer status) {
        super(ResultConstant.SERVICE_ERROR.message());
        this.status = status;
    }

    protected BaseException(Integer status, String message) {
        super(message);
        this.status = status;
    }

    @Override
    public StackTraceElement[] getStackTrace() {
        return ArrayUtil.filter(super.getStackTrace(), stackTraceElement ->
                !("of".equals(stackTraceElement.getMethodName())
                        && getClass().getName().equals(stackTraceElement.getClassName())));
    }
}
